package com.neuedu.springmvc.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

// import javax.servlet.http.HttpServletRequest;

/**
 * @author 金山
 * 项目：springmvc-learn
 * site: https://blog.fulfill.com.cn
 * 描述
 * @data 2025/3/149:44
 */
@Controller
@RequestMapping("/user")
public class UserController {


    /**
     * http://localhost:8080/web/user/list
     * @return
     */
    @ResponseBody
    @RequestMapping("/list")
    public String list(){
        return "list-success";
    }


    /**
     *      * http://localhost:8080/web/user/save?name=zhangfei
     * @return
     */
    @ResponseBody
    @RequestMapping("/save")
    public String save(HttpServletRequest request){

        String name =   request.getParameter("name");

        System.out.println("name = " + name);
        return "save-success";
    }

    @ResponseBody
    @RequestMapping("/save2")
    public String save2(String name,int age){

        System.out.println("name = " + name);
        System.out.println("age = " + age);
        return "save-success";
    }
}
